package com.maybach.workflow.core.processor;


import com.maybach.util.AssertUtil;
import com.maybach.workflow.common.api.enums.NodeTypeEnum;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by houenxun on 15/8/13.
 */
public class ProcessorFactory {

    public  void setProcessorMap(Map<String, IProcessor> map) {
        ProcessorFactory.processorMap = map;
    }

    private static Map<String, IProcessor> processorMap = new HashMap<String, IProcessor>();


    public static  IProcessor  getProcessor(String name){
        AssertUtil.notBlank(name, "name");
        return processorMap.get(name);
    }

    public static  IProcessor  getProcessor(NodeTypeEnum nodeType){
        AssertUtil.notNull(nodeType, "nodeType");
        return getProcessor(nodeType.name());
    }
}
